import { reqUserAddress, reqTradeList } from '@/api'

const actions = {
    async getUserAddress({ commit }) {
        let result = await reqUserAddress();
        if (result.code == 200) {
            commit("GETUSERADDRESS", result.data);
        }
    },

    async getTradeList({ commit }) {
        let result = await reqTradeList();
        if (result.code == 200) {
            commit("GETTRADELIST", result.data)
        }
    }
};

const mutations = {
    GETUSERADDRESS(state, data) {
        state.userAddress = data
    },

    GETTRADELIST(state, data) {
        state.tradeList = data
    }
};

const state = {
    userAddress: [],
    tradeList: {}
};

export default {
    actions, mutations, state
}